package com.xxl.job;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * xxl-job 执行器启动类
 *
 * @version : 1.0
 * @author  : zyc
 * @date    : 2023/9/2 10:42
 */
@Slf4j
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
@EnableTransactionManagement
public class XxlJobExecutorApplication {
	public static void main(String[] args) throws UnknownHostException {
		ConfigurableApplicationContext application = SpringApplication.run(XxlJobExecutorApplication.class, args);
		Environment env = application.getEnvironment();
		String ip = InetAddress.getLocalHost().getHostAddress();
		String port = env.getProperty("server.port");
		log.info("\n---------------------------------------------------------\n\t" +
				"Application xxl-job-execute is running! Access URLs:\n\t" +
				"Local: \t\thttp://localhost:" + port  + "/\n\t" +
				"External: \thttp://" + ip + ":" + port  + "/\n\t" );
		log.info("-----------------------------------------------------------");
	}
}